Received: from svcs1.digex.net (svcs1.digex.net [204.91.197.224]) by mail1.access.digex.net (8.6.12/8.6.12) with ESMTP id KAA13480; for <mcox@access.digex.net> ; Fri, 15 Dec 1995 10:41:23 -0500
Received: (from daemon@localhost) by svcs1.digex.net (8.6.12/8.6.12) id GAA07155 for amos-out; Fri, 15 Dec 1995 06:42:47 -0500
Received: from mail1.access.digex.net (mail1.access.digex.net [205.197.247.2]) by svcs1.digex.net (8.6.12/8.6.12) with ESMTP id GAA07150 for <amos-list@svcs1.digex.net>; Fri, 15 Dec 1995 06:42:43 -0500
Received: from paaltjens.si.hhs.nl (pp@paaltjens.si.hhs.nl [145.52.80.3]) by mail1.access.digex.net (8.6.12/8.6.12) with SMTP id GAA18914; for <amos-list@access.digex.net> ; Fri, 15 Dec 1995 06:42:36 -0500
From: v942360@si.hhs.nl
Received: from si.hhs.nl by paaltjens.si.hhs.nl
id <13859-0@paaltjens.si.hhs.nl>; Fri, 15 Dec 1995 12:41:25 +0100
Received: by brulez.si.hhs.nl (5.0/SMI-SVR4) id AA07904;
Fri, 15 Dec 1995 12:39:49 --100
Date: Fri, 15 Dec 1995 12:39:49 --100
Message-Id: <9512151139.AA07904@brulez.si.hhs.nl>
To: amos-list@access.digex.net
Subject: Re: Help me a little. Please!
X-Sun-Charset: US-ASCII
content-length: 2647
Status: RO
X-Status:
nygren@wineasy.se (Anders Nygren) wrote a plea FOR HELP ON 11.12.1995.
He also got a reply from Chris hodges, however, I have something to add.
First he asked some questions, after wich he asked the following one:
> AN> and is it possible
> AN> to redimension a variable after I already have dimensioned it?
>
> No. For your file requester thingy, I would use a bank for the directory
> data or an array of fixed maximum size for the data.
Now, in a way Chris is correct, you cannot redimension an array after you have dimensioned it, but, look at this:
Rem Global or non global??
Rem That's the question.
Rem a simple example, by Jeroen Knoester (v942360@si.hhs.nl)
'
Rem Global vars:
Dim array1(10,10)
Global array1()
Rem now this array can never be altered in size, but...
'
Procedure example
Rem Create an array
count=Rnd(100)
Print count
'
Dim array2(count)
Rem this array is now dimensioned, right..
Rem So.. it cannot be altered in size, right..
Rem Correct, BUT this is a LOCAL array.. If the procedure is exited
Rem and then reentered later, the main program will have forgotten all
Rem about the array, so.. It will locally redimension the array, with a
Rem different size.
'
End Proc
'
Rem Main loop
'
While inkey$=""
example
Wend
End
This little program will show you the benefits of local vars over global ones.
What happens is this:
In the main program, the computer knows nothing about the array in the procedure
example. While inside the procedure, the array is dimensioned, with a random
size. When this procedure is exited, the computer will totally forget the
array dimensioned INSIDE the procedure. When the program then calls the procedure again, the computer will redimension the array, simply because according to the computer, the array is not there.
This poses a single problem, how to get the information you need from this procedure to the outside world..
Well, you use a single global var as help. What you do is this:
You read the information you need from your file selector, wich is a single file. This information you stick into a global var from the main program BEFORE you
exit the procedure. This way you can redimension your array, and still get the
information you need from it.
If you need the array to be known among multiple procedures, you simply declare it as a Shared var in the other procedure to use the array, like this:
Procedure Needs_your_array
Shared array()
Rem code goes here..
End Proc
I hope this helps... See you,
Jeroen Knoester, v942360@si.hhs.nl
--Check out the Power Programs homepage at http://www.si.hhs.nl/~v942360/Amiga.html-- A500, 68000 7 Mhz!! Still running!!